bitkeeper revision 1.1159.17.14 (411b1b16kI8OhQTxCf1kbM8dV6LXcA)
authoriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>
Thu, 12 Aug 2004 07:24:06 +0000 (07:24 +0000)
committeriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>
Thu, 12 Aug 2004 07:24:06 +0000 (07:24 +0000)
prepare 2.6 blkfront for suspend/resume

linux-2.6.7-xen-sparse/drivers/char/mem.c
linux-2.6.7-xen-sparse/drivers/xen/blkfront/blkfront.c
tools/misc/xen-clone

index 5dba3aee4657205df355c974156ed022d4de1f94..ceea2b5ffdef35e0ca7a099dcb64226e1193db09 100644 (file)
@@ -252,7 +252,7 @@ static int mmap_mem(struct file * file, struct vm_area_struct * vma)
        vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
        if (direct_remap_area_pages(vma->vm_mm, vma->vm_start, offset, 
                                vma->vm_end-vma->vm_start, vma->vm_page_prot,
-                               (domid_t)file->private_data))
+                               (domid_t)(unsigned long)file->private_data))
                return -EAGAIN;
        return 0;
 }
index 9d326f6a3520cc5fca56671b121d75a1489aca2c..da7aa2bfe6cee04a90743d9f2040cfbd04b26a6e 100644 (file)
@@ -50,6 +50,32 @@ static int recovery = 0;           /* "Recovery in progress" flag.  Protected
 static request_queue_t *pending_queues[MAX_PENDING];
 static int nr_pending;
 
+inline void translate_req_to_pfn( blkif_request_t * xreq, blkif_request_t * req)
+{
+    int i;
+    
+    *xreq=*req; 
+    for ( i=0; i<req->nr_segments; i++ )
+    {  
+       xreq->frame_and_sects[i] = (req->frame_and_sects[i] & ~PAGE_MASK) |
+           (machine_to_phys_mapping[req->frame_and_sects[i]>>PAGE_SHIFT]<<PAGE_SHIFT); 
+    }
+    return xreq;
+}
+
+inline void translate_req_to_mfn( blkif_request_t * xreq, blkif_request_t * req)
+{
+    int i;
+
+    *xreq=*req; 
+    for ( i=0; i<req->nr_segments; i++ )
+    {  
+       xreq->frame_and_sects[i] = (req->frame_and_sects[i] & ~PAGE_MASK) |
+           (phys_to_machine_mapping[req->frame_and_sects[i]>>PAGE_SHIFT]<<PAGE_SHIFT);
+    }
+    return xreq;
+}
+
 static inline void flush_requests(void)
 {
 
@@ -243,8 +269,10 @@ static int blkif_queue_request(struct request *req)
        req_prod++;
 
         /* Keep a private copy so we can reissue requests when recovering. */
-        blk_ring_rec->ring[MASK_BLKIF_IDX(blk_ring_rec->req_prod)].req =
-                *ring_req;
+        translate_req_to_pfn(
+           &blk_ring_rec->ring[MASK_BLKIF_IDX(blk_ring_rec->req_prod)].req,
+            ring_req);
+
         blk_ring_rec->req_prod++;
 
         return 0;
@@ -407,9 +435,10 @@ void blkif_control_send(blkif_request_t *req, blkif_response_t *rsp)
         goto retry;
     }
 
-    memcpy(&blk_ring->ring[MASK_BLKIF_IDX(req_prod)].req, req, sizeof(*req));
-    memcpy(&blk_ring_rec->ring[MASK_BLKIF_IDX(blk_ring_rec->req_prod++)].req,
-           req, sizeof(*req));
+    blk_ring->ring[MASK_BLKIF_IDX(req_prod)].req = *req;    
+    translate_req_to_pfn(&blk_ring_rec->ring[
+       MASK_BLKIF_IDX(blk_ring_rec->req_prod++)].req,req);
+
     req_prod++;
     flush_requests();
 
@@ -497,9 +526,9 @@ static void blkif_status_change(blkif_fe_interface_status_changed_t *status)
 
         if ( recovery )
         {
-            int i;
+            int i,j;
 
-           /* Shouldn't need the blkif_io_lock here - the device is
+           /* Shouldn't need the io_request_lock here - the device is
             * plugged and the recovery flag prevents the interrupt handler
             * changing anything. */
 
@@ -507,18 +536,24 @@ static void blkif_status_change(blkif_fe_interface_status_changed_t *status)
             for ( i = 0;
                  resp_cons_rec < blk_ring_rec->req_prod;
                   resp_cons_rec++, i++ )
-            {
-                blk_ring->ring[i].req
-                    = blk_ring_rec->ring[MASK_BLKIF_IDX(resp_cons_rec)].req;
+            {                
+                translate_req_to_mfn(&blk_ring->ring[i].req,
+                                    &blk_ring_rec->ring[
+                                        MASK_BLKIF_IDX(resp_cons_rec)].req);
             }
 
-            /* Reset the private block ring to match the new ring. */
-            memcpy(blk_ring_rec, blk_ring, sizeof(*blk_ring));
+            /* Reset the private block ring to match the new ring. */      
+           for( j=0; j<i; j++ )
+           {           
+               translate_req_to_pfn(
+                   &blk_ring_rec->ring[j].req,
+                   &blk_ring->ring[j].req);
+           }
+
             resp_cons_rec = 0;
 
             /* blk_ring->req_prod will be set when we flush_requests().*/
             blk_ring_rec->req_prod = req_prod = i;
-
             wmb();
 
             /* Switch off recovery mode, using a memory barrier to ensure that
@@ -677,4 +712,14 @@ void blkdev_suspend(void)
 
 void blkdev_resume(void)
 {
+    ctrl_msg_t                       cmsg;
+    blkif_fe_driver_status_changed_t st;    
+
+    /* Send a driver-UP notification to the domain controller. */
+    cmsg.type      = CMSG_BLKIF_FE;
+    cmsg.subtype   = CMSG_BLKIF_FE_DRIVER_STATUS_CHANGED;
+    cmsg.length    = sizeof(blkif_fe_driver_status_changed_t);
+    st.status      = BLKIF_DRIVER_STATUS_UP;
+    memcpy(cmsg.msg, &st, sizeof(st));
+    ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
 }
index 392bf8c6feaf643b317bcafb6692ca9753506fa8..ce650f5dd85580a87d8d012cc99899a47c349f9d 100755 (executable)
@@ -72,7 +72,7 @@ then
  make -j4 world
  make -j4 linux26
  cd ../install/boot
- [ -r vmlinuz-${LINUX_VER}-xen0 ] && ln -s vmlinuz-${LINUX_VER}-xen0 xenolinux.gz
+ [ -r vmlinuz-2.4.*-xen0 ] && ln -s vmlinuz-2.4.*-xen0 xenolinux.gz
   
 else
  # old style repository without 'make world'